package immutablecollections.functions;

import immutablecollections.*;

class DelegateInvoker<O> extends Invoker<O>
{

    final private  Invoker<O> delegate;
    final private  Object firstArg;

    public DelegateInvoker(Invoker<O> m, Object firstArg)
    {
        this.delegate = m;
        this.firstArg = firstArg;
    }

    @Override
    O invoke(ImList<Object> args)
    {
        return delegate.invoke(ImList.cons(firstArg, args));
    }

    @Override
    public String toString(ImList<Object> args)
    {
        return delegate.toString(ImList.cons(firstArg, args));
    }

    @Override
    public String toString()
    {
        return delegate.toString(ImList.cons(firstArg, (ImList<Object>) ImList.empty()));
    }

}
